package com.beiding.fastmock.config;

import com.beiding.dbrequest.common.Dispatcher;
import com.beiding.dbrequest.server.Server;
import com.beiding.fastmock.plugin.PluginController;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 丁常磊
 * @date 2021/7/17 11:16
 */

@Configuration
public class PluginConfig {

    @Value("${fastmock.plugin.port}")
    private Integer pluginPort;

    @Bean
    public Dispatcher dispatcher() {
        return new Dispatcher();
    }

    @Bean
    public Server server(PluginController pluginController) {
        Server server = new Server().port(pluginPort).dispatcher(dispatcher()).addController(pluginController);
        server.start().syncR();
        return server;
    }

}
